package hotgammon.view.tools;

import hotgammon.view.*;
import minidraw.framework.Tool;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;

public class DieRollTool implements Tool {
    private BackgammonUserInterface ui;
    
    public DieRollTool(BackgammonUserInterface ui) {
        this.ui = ui;
    }
    
  /**
   * Activates the tool for the given view. This method is called
   * whenever the user switches to this tool. Use this method to
   * reinitialize a tool.
   */
  public void activate() {
      
  }
  
  /**
   * Deactivates the tool. This method is called whenever the user
   * switches to another tool. Use this method to do some clean-up
   * when the tool is switched. Subclassers should always call
   * super.deactivate.
   */
  public void deactivate() {
      
  }
  
  /**
   * Handles mouse down events in the drawing view.
   */
  public void mouseDown(MouseEvent e, int x, int y) {
      int dieSide = 33;
      System.out.println("roll");
      
      if(y >= 202 && y <= 202 + dieSide) {
        if((x >= 216 && x <= 216 + dieSide) || (x >= 306 && x <= 306 + dieSide)) {
            ui.getGame().nextTurn();
            //ui.getGame().diceThrown();
        }
      }
  }
  
  /**
   * Handles mouse drag events in the drawing view.
   */
  public void mouseDrag(MouseEvent e, int x, int y) {
      
  }
  
  /**
   * Handles mouse up in the drawing view.
   */
  public void mouseUp(MouseEvent e, int x, int y) {
      
  }
  
  /**
   * Handles mouse moves (if the mouse button is up).
   */
  public void mouseMove(MouseEvent evt, int x, int y) {
      
  }
  
  /**
   * Handles key down events in the drawing view.
   */
  public void keyDown(KeyEvent evt, int key) {
      
  }

  /**
   * Return the editor this tool is associated with.
   */
  //  public DrawingEditor editor();
    
}
